<%inherit file="base.html"/>

<h2>${application['name']}</h2>
<div id="tabNav">
    <ul>
        <li><a href="/application/">${_('Info')}</a></li>
        <li class="selected"><a href="/application/create/">${_('Create')}</a></li>
        % if is_owner:
        <li><a href="/application/manage/">${_('Manage')}</a></li>
        % endif
    </ul>
    <div class="clr"><br/></div>
</div>
<div id="leftPanel">
    <img src="${application['picture']}" alt=""/>

    <div class="sideWidget">
        <h3>
            ${_('Info')}
        </h3>

        <table class="personal">
        <tr>
            <th>${_('version')}</th>
            <td>${application['system']['version']}</td>
        </tr>
        % if application['system']:
        <tr>
            <th>${_('can add to personal profile?')}</th>
            <td>${application['system']['principal_aware']}</td>
        </tr>
        <tr>
            <th>${_('can add to group?')}</th>
            <td>${application['system']['group_aware']}</td>
        </tr>
        % endif
        </table>
    </div>
</div>
<div id="mainPanel">
    % if not application['system']['principal_aware'] and not application['system']['group_aware']:
    <div class="section" id="info">
        <h3>${_('Cannot create content')}</h3>
        <p class="intro">${_('You cannot create content using this application.')}</p>
    </div>
    % endif
    % if application['system']['principal_aware']:
    <div class="section" id="installPerson">
        <h3>${_('Add to your profile')}</h3>
        % if errors:
            <div class="alert">${message}</div>
        % endif
        <p class="intro">
            ${('Use the form below to add new content to your profile.')}
        </p>
        <div class="installForm">
            <form id="installForm" action="/application/create/#installPerson" method="post">
                <dl>
                    <dt>
                        <input type="hidden" name="appiid" value="${application['iid']}"/>
                        <label for="title">${_('Title:')}</label>
                    </dt>
                    <dd>
                        <input type="text" class="text" id="title" name="title" value="${dirty.get('title')}"/>
                    </dd>
                    <dt></dt>
                    <dd>
                        <input type="radio" class="radio" name="public_link" value="no" id="public_link_no"
                        % if dirty['public'] == 'no': 
                            checked="checked"
                        % endif 
                        />
                        <label for="public_link_no">${_('Restrict this to my friends only')}</label>
                        <br/>

                        <input type="radio" class="radio" name="public_link" value="yes" id="public_link_yes"
                        % if dirty['public'] == 'yes': 
                            checked="checked"
                        % endif 
                        />
                        <label for="public_link_yes">${_('Make this public')}</label>
                    </dd>
                    <dd class="buttons">
                        <input type="submit" class="submit nowrap" value="${_('Create')}"/>
                    </dd>
                </dl>
            </form>
        </div>
        <div class="clr"><br/></div>
    </div>
    % endif

    % if application['system']['group_aware']:
    <div class="section" id="installGroup">
        <h3>Add to a group</h3>
        % if errors_group:
            <div class="alert">${message_group}</div>
        % endif
        <p class="intro">
            ${_('Use the form below to add new content to one of your groups.')}
        </p>
        <div class="installForm">
            <form id="groupInstallForm" action="/application/create/#installGroup" method="post">
                <dl>
                    <dt>
                        <input type="hidden" name="appiid" value="${application['iid']}"/>
                        <input type="hidden" name="add_to_group" value="True"/>
                        <label for="title_group">${_('Title:')}</label>
                    </dt>
                    <dd>
                        <input type="text" class="text" id="title_group" name="title" value="${dirty.get('title_group')}"/>
                    </dd>
                    <dt>
                        <label for="group">${_('Group:')}</label>
                    </dt>
                    <dd>
                        <select id="group" name="group">
                            <option value="null">Please select a group</option>
                            % for giid in group_list['index']:
                                % if group_list['items'][giid]['stable'] and group_list['items'][giid]['is_admin']:
                                    <option value="${giid}">${group_list['items'][giid]['name']}</option>
                                % endif
                            % endfor
                        </select>
                    </dd>
                    <dt></dt>
                    <dd>
                        <input type="radio" class="radio" name="public_link" value="no" id="public_group_link_no"
                        % if dirty['public_group'] == 'no': 
                            checked="checked"
                        % endif 
                        />
                        <label for="public_group_link_no">${_('Restrict this to group members only')}</label>
                        <br/>

                        <input type="radio" class="radio" name="public_link" value="yes" id="public_group_link_yes"
                        % if dirty['public_group'] == 'yes': 
                            checked="checked"
                        % endif 
                        />
                        <label for="public_group_link_yes">${_('Make this public')}</label>
                    </dd>
                    <dd class="buttons">
                        <input type="submit" class="submit" value="${_('Create')}"/>
                    </dd>
                </dl>
            </form>
        </div>
        <div class="clr"><br/></div>
    </div>
</div>
% endif

<!-- defs -->
<%def name="title()">P2P Fusion - Peerscape | ${application['name']} | ${_('Create')}</%def>
<%def name="body_class()">application profile</%def>

<%def name="notifications()">
</%def>
